{include file="public/headerbase" /}
{include file="public/left" /}
		<div class="right-content">
	<div class="we7-page-title">
		菜单管理
	</div>
	<ul class="we7-page-tab"></ul>
	<div class="js-menu-container" ng-controller="MenuCtrl" ng-cloak>
		<div class="we7-padding-bottom clearfix">
			<div class="pull-right">
				<a href="javascript:;" class="btn btn-primary we7-padding-horizontal" data-toggle="modal" data-target="#pass">+新建菜单</a>
			</div>
		</div>
		<!-- 顶级菜单添加页面 -->
			<div class="modal fade" id="pass" role="dialog">
			<div class="we7-modal-dialog modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
						<div class="modal-title">编辑菜单</div>
					</div>
					<div class="modal-body text-center">
						<div class="we7-form" style="width: 450px; margin: 0 auto;">
							<div class="form-group">
								<label for="" class="control-label col-sm-2">菜单名称</label>
								<div class="form-controls col-sm-10">
									<input type="text" name="mname" value="" id="mname" class="form-control old-password">
								</div>
							</div>
							<div class="form-group">
								<label for="" class="control-label col-sm-2">菜单连接</label>
								<div class="form-controls col-sm-10">
									<input type="text" name="murl" value="" id="murl" class="form-control new-password">
								</div>
							</div>
							<div class="form-group">
								<label for="" class="control-label col-sm-2">菜单位置</label>
								<div class="form-controls col-sm-10">
									<input type="text" name="mplace" value="0" id="mplace" class="form-control renew-password">
								</div>
							</div>
						</div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-primary" onclick="onemenu()">保存</button>
						<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
					</div>
				</div>
			</div>
			</div>
		<table class="table we7-table table-hover article-list">
			<col width="150px" />
			<col width="456px" />
			<col width="90px" />
			<col width="300px" />
			<tr>
				<th class="text-left"><!-- 排序 --></th>
				<th class="text-left">菜单名称</th>
				<th>显示</th>
				<th>操作</th>
			</tr>
			{foreach name="cat" item="val"}
			<!-- 一级菜单显示 -->
			<tr>
				<td class="text-left"></td>
				<td class="text-left">
					<span>{$val.mname}</span>
				</td>
				<td></td>
				<td class="text-right we7-padding-right">
					<a href="javascript:;" class="color-default we7-margin-right-sm" data-toggle="modal" data-target="#onelist{$val.mid}">+{$val.mid}添加下级分类</a>
				</td>
			</tr>
			<!-- 一级菜单添加页面 -->
			<div class="modal fade" id="onelist{$val.mid}" role="dialog">
				<div class="we7-modal-dialog modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
							<div class="modal-title">编辑菜单</div>
						</div>
						<div class="modal-body text-center">
							<div class="we7-form" style="width: 450px; margin: 0 auto;">
								<div class="form-group">
									<label for="" class="control-label col-sm-2">菜单名称</label>
									<div class="form-controls col-sm-10">
										<input type="text" name="mname" id="twomname" value="" class="form-control old-password">
									</div>
								</div>
							</div>
							<div class="we7-form" style="width: 450px; margin: 0 auto;">
								<div class="form-group">
									<label for="" class="control-label col-sm-2">菜单位置</label>
									<div class="form-controls col-sm-10">
										<input type="text" name="mplace" id="twopalce" value="1" class="form-control old-password">
									</div>
								</div>
							</div>
						</div>
						<div class="modal-footer">
							<button type="button" class="btn btn-primary" onclick="twomenu({$val.mid})">保存</button>
							<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
						</div>
					</div>
				</div>
			</div>
			<!-- 二级菜单展示 -->
			{foreach name="val['child']" item="vo"}
			<tr>
				<td class="text-left">
					<div class="pad-bottom "></div>
				</td>
				<td class="text-left">
					<span style="margin-left: 25px;">{$vo.mname}</span>
				</td>
				<td></td>
				<td class="text-right we7-padding-right">
					<a href="javascript:;" class="color-default we7-margin-right-sm" data-toggle="modal" data-target="#twolist{$vo.mid}">+{$vo.mid}添加下级分类</a>
				</td>
			</tr>
			<!-- 二级菜单添加页面 -->
			<div class="modal fade" id="twolist{$vo.mid}" role="dialog">
					<div class="we7-modal-dialog modal-dialog">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
								<div class="modal-title">编辑菜单1</div>
							</div>
							<div class="modal-body text-center">
								<div class="we7-form" style="width: 450px; margin: 0 auto;">
									<!-- <div class="form-group">
										<label for="" class="control-label col-sm-2">菜单排序</label>
										<div class="form-controls col-sm-10">
											<input type="text" value="" class="form-control old-password">
										</div>
									</div> -->
									<div class="form-group">
										<label for="" class="control-label col-sm-2">菜单名称</label>
										<div class="form-controls col-sm-10">
											<input type="text" name="mname" id="threemname" value="" class="form-control new-password">
										</div>
									</div>
									<div class="form-group">
										<label for="" class="control-label col-sm-2">菜单链接</label>
										<div class="form-controls col-sm-10">
											<input type="text" name="murl" id="threeurl" value="" class="form-control renew-password">
										</div>
									</div>
									<div class="form-group">
										<label for="" class="control-label col-sm-2">菜单位置</label>
										<div class="form-controls col-sm-10">
											<input type="text" name="mplace" id="threepalce" value="2" class="form-control old-password">
										</div>
									</div>
								</div>
							</div>
							<div class="modal-footer">
								<button type="button" class="btn btn-primary" onclick="threemenu({$vo.mid})">保存</button>
								<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
							</div>
						</div>
					</div>
				</div>
				{foreach name="vo['child']" item="vs"}
				<!-- 三级菜单展示 -->
				<tr class="bg-light-gray">
					<td class="text-left">
						<div class="pad-bottom "><!-- 6 --></div>
					</td>
					<td class="text-left">
						<span style="margin-left: 60px;">{$vs.mname}</span>
					</td>
					<td>
						<div class="switch" ng-init="displayStatus['platform_reply'] = true" ng-click="changeDisplay('platform_reply')" ng-class="{'switchOn' : displayStatus['platform_reply'], 'switchOff' : !displayStatus['platform_reply']}"></div>
					</td>
					<td class="text-right we7-padding-right">
						<div class="link-group">
							<a href="javascript:;" class="we7-margin-right-sm" ng-click="editItemPanel({displayorder: '6', title : '自动回复', url : './index.php?c=platform&a=reply&', permissionName : 'platform_reply', isSystem : '1', id : '', 'group' : ''})">编辑</a>
						</div>
					</td>
				</tr>
				<!-- 编辑页面 -->
				<div class="modal fade bs-example-modal-sm js-edit-panel" id="edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog we7-modal-dialog ">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
								<h4 class="modal-title">编辑菜单</h4>
							</div>
							<form action="" method="post" enctype="multipart/form-data" class="we7-form form">
								<div class="modal-body">
									<div class="form-group" ng-hide="activeItem.group == 'frame'">
										<label class="col-sm-2 control-label">菜单排序</label>
										<div class="col-sm-10">
											<input type="text" name="displayorder" ng-model="activeItem.displayorder" class="form-control">
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label">菜单名称</label>
										<div class="col-sm-10">
											<input type="text" name="title" ng-model="activeItem.title" class="form-control">
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label"> 菜单标识</label>
										<div class="col-sm-10">
											<input type="text" name="permission_name" ng-readonly="activeItem.isSystem == '1'" ng-model="activeItem.permissionName" class="form-control">
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label"> 菜单链接</label>
										<div class="col-sm-10">
											<input type="text" name="url" ng-readonly="activeItem.isSystem == '1'" ng-model="activeItem.url" class="form-control">
										</div>
									</div>
									<div class="form-group" ng-hide="activeItem.isSystem == '1' || activeItem.group == 'frame'">
										<label class="col-sm-2 control-label"> 菜单图标</label>
										<div class="col-sm-10">
											<div class="input-group">
												<input type="text" name="icon" value="" ng-model="activeItem.icon" class="form-control">
												<span class="input-group-addon" style="width:35px; border-left:none"><i class="fa fa-external-link"></i></span>
												<span class="input-group-btn"> <a href="javascript:;" class="btn btn-default" ng-click="selectMenuIcon();">&nbsp;选择图标</a></span>
											</div>
										</div>
									</div>
								</div>
								<div class="modal-footer">
									<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
									<button type="button" class="btn btn-primary" name="submit" value="保存" ng-click="editItem()">保存</button>
								</div>
							</form>
						</div>
					</div>
				</div>
				{/foreach}
			{/foreach}
			{/foreach}	
		</table>
	</div>
	<script type="text/javascript">
		$(function() {
			angular.bootstrap($('.js-menu-container'), ['systemApp']);
		});
		//一级菜单
		function onemenu(){
			var mname=$("#mname").val();
			var murl=$("#murl").val();
			var mplace=$("#mplace").val();
			$.ajax({
	        url: "{:url('Menu/addonemenu')}",
	        data:{'mname':mname,"murl":murl,"mplace":mplace},
	        type: "post",
	        dataType: "json",
	        success: function (mega) {
	          if(mega==1){
	           		util.message('添加菜单成功', '', '');
	           }else{
	           		util.message('添加失败', '', '');
	           }
	        }
    	});
		}
		// 二级菜单
		function twomenu(mid){
			alert(mid);
			var mname=$("#twomname").val();
			alert(mname);
			var mplace=$("#twopalce").val();
			alert(mplace);
			// $.ajax({
	  //       url: "{:url('Menu/addtwomenu')}",
	  //       data:{'mname':mname,"mplace":mplace,"parent_cid":mid},
	  //       type: "post",
	  //       dataType: "json",
	  //       success: function (megb) {
	  //         if(megb==1){
	  //          		util.message('添加菜单成功', '', '');
	  //          }else{
	  //          		util.message('添加失败', '', '');
	  //          }
	  //       }
   //  	});
		}
		//三级菜单
		function threemenu(mid){
			// alert(mid);
			var mname=$("#threemname").val();
			// alert(mname);
			var murl=$("#threeurl").val();
			// alert(murl);
			var mplace=$("#threepalce").val();
			// alert(mplace);
			$.ajax({
	        url: "{:url('Menu/addthreemenu')}",
	        data:{'mname':mname,"murl":murl,"mplace":mplace,"parent_cid":mid},
	        type: "post",
	        dataType: "json",
	        success: function (megc) {
	          if(megc==1){
	           		util.message('添加菜单成功', '', '');
	           }else{
	           		util.message('添加失败', '', '');
	           }
	        }
    	});
		}
	</script>
</div>
{include file="public/footer" /}